<!DOCTYPE html>
<html>
<head>

</head>
<body>
    <script>
        function getAttr(){
            var a1 = document.getElementById("a1");
            alert(a1.getAttribute("href"));
        }
        function setAttr(){
            var a1 = document.getElementById("a1");
            a1.setAttribute("href","http://www.jredu100.com");
            console.log(a1.href);
        }
    </script>
    <button onclick="getAttr()">取到a的href属性值</button>
    <button onclick="setAttr()">修改a的href属性值</button>
    <a href="http://www.baidu.com" id="a1">这是一个超链接</a>
</body>
 </html>